// 场景管理
controllers.controller('tranDetailListCtrl', ['$scope', '$http', '$rootScope', '$modal', '$window', 'TranDetail', 'AlertService', function ($scope, $http, $rootScope, $modal, $window, TranDetail, AlertService) {
    $scope.resetCurrentPageName("V币维护");
    $scope.utils = Food.utils;
    $scope.pageSize = 20;
    $scope.currentPage = 1;
    $scope.tranDetailList = TranDetail.tranDetailList;

    $scope.queryList = function () {
        TranDetail.queryList($scope.currentPage, $scope.pageSize, $scope.tranNo, $scope.memberId, $scope.memberName,  $scope.income, $scope.payout, $scope.preBalance, $scope.curBalance, $scope.tranType, $scope.userAdd, $scope.remark, function () {
            $scope.totalCount = TranDetail.totalCount;
        });
    };
    $scope.downItem = function (itemId) {
        Item.downItem(itemId, function () {
            $scope.totalItems = Item.totalSceneCount;
        });
    };
    $scope.initUpdateItem = function (item) {

        Item.currentItem = item;
        $window.location.href = "#item/updateItem";

    };
    $scope.queryList();

    var operateTemplate = "<button class='btn btn-primary btn-sm' ng-click='grid.appScope.initUpdateItem(row.entity)'>修改</button>" +
        "<button class='btn btn-primary btn-sm' ng-click='grid.appScope.downItem(row.entity.id)'>下架</button>";

    $scope.gridOptions = {
        data: 'tranDetailList',
        enableColumnMenus: false,
        enableColumnResizing: true,
        rowHeight: 100,
        columnDefs: [
        
            {
                field: 'tranNo',
                displayName: 'tranNo',
                cellTemplate: '<div>{{row.entity.tranNo}}</div>'
            },

            {
                field: 'memberId',
                displayName: '会员ID',
                cellTemplate: '<div>{{row.entity.memberId}}</div>'
            },
            {
                field: 'memberName',
                displayName: '会员名称',
                width: "10%",
                cellTemplate: '<div>{{row.entity.memberName}}</div>'
            },
            {
                field: 'tranType',
                displayName: 'tran类型',
                cellTemplate: '<div>{{row.entity.tranType}}</div>'
            },
             {
                field: 'income',
                displayName: 'income',
                cellTemplate: '<div>{{row.entity.income}}</div>'
            },
            {
                field: 'payout',
                displayName: 'payout',
                cellTemplate: '<div>{{row.entity.payout}}</div>'
            },
             {
                field: 'preBalance',
                displayName: 'preBalance',
                cellTemplate: '<div>{{row.entity.preBalance}}</div>'
            },
             {
                field: 'curBalance',
                displayName: 'curBalance',
                cellTemplate: '<div>{{row.entity.curBalance}}</div>'
            },                  
            
            {
                field: 'userAdd',
                displayName: '用户增加',
                cellTemplate: '<div>{{row.entity.userAdd}}</div>'
            },
            {
                field: 'remark',
                displayName: '备注',
                cellTemplate: '<div>{{row.entity.remark}}</div>'
            }
        ]
    };
}]);


